﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core
{
    public class ChainFinder
    {
        protected Chainer chainer;

        public ChainFinder(Chainer chainer)
        {
            if (chainer == null)
                throw new ArgumentException();
            this.chainer = chainer;
        }

        public Chain[] Find(String text)
        {
            return chainer.ClosedChains
                .Where(chain => chain.Lines
                    .Any(l => l.Text.Contains(text)))
                .ToArray();
        }
    }
}
